package com.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.model.Response;
import com.service.StatisticsService;

@Controller
public class CacheController {
	@Autowired
	private StatisticsService statisticsService;

	/**
	 * getCachedModels和getCacheCp方法的service层方法使用了同名的缓存，哪个方法先调用哪个的返回值先存入缓存
	 * 
	 * @return
	 */
	@RequestMapping("getCache.do")
	@ResponseBody
	public Response getCachedModels() {
		return new Response(statisticsService.getAll("ka"));
	}

	@RequestMapping("getCache_cp.do")
	@ResponseBody
	public Response getCacheCp() {
		return new Response(statisticsService.getAll_Cp("kb"));
	}

	@RequestMapping("removeCache.do")
	@ResponseBody
	public Response removeCache() {
		statisticsService.removeCache();
		return new Response();
	}
}
